cmake_minimum_required(VERSION 3.16)

#------------------------
# Project setting
#------------------------
set(APP_NAME moderncpp)
set(APP_VERSION 1.0.0)
set(BIN_DIR bin)
set(DOC_DIR /share/doc/cmake/)

project(${APP_NAME} VERSION ${APP_VERSION} LANGUAGES CXX C)
# GoogleTest requires at least C++17
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

message(INFO "-------------------------------")
message(STATUS "Build ${APP_NAME}: ${APP_VERSION}")

add_executable(ctor src/ctor/ctor.cc)
add_executable(uniform_init src/basic/uniform_init.cc)
add_executable(arr_negative_idx src/basic/array_negative_idx.cc)
add_executable(ref src/basic/reference.cc)
add_executable(bit src/basic/bit.cc)
add_executable(addr_of src/basic/addr_of.cc)
add_executable(perfect_forwarding src/basic/perfect_forwarding.cc)
add_executable(initializer_list src/initialization/initializer_list.cc)
add_executable(str_basic src/string/str_basic.cc)
add_executable(custom_deleter src/smart_pointers/custom_deleter.cc)
add_executable(cast src/casting/cast.cc)
add_executable(rvo src/rvo/rvo.cc)
add_executable(range src/ranges/range.cc)
add_executable(constexpr_func src/constexpr/constexpr_func.cc)
add_executable(time src/time/time.cc)
add_executable(lambda src/lambda/lambda.cc)
add_executable(file_iter src/iterator/file_iter.cc)


# unit test enable
include(FetchContent)
FetchContent_Declare(
  googletest
  GIT_REPOSITORY https://github.com/google/googletest.git
  GIT_TAG release-1.12.1
  )

FetchContent_MakeAvailable(googletest)

enable_testing()

add_executable(hello_test tests/hello_test.cc)

target_link_libraries(hello_test GTest::gtest_main)

include(GoogleTest)
gtest_discover_tests(hello_test)

